<?php
// select uid from uinfo group by uid having count(uid) >1 ORDER BY `uinfo`.`uid` ASC
//select phone from uinfo where fen > 0 group by phone having count(phone) >1 ORDER BY `uinfo`.`phone` ASC
set_time_limit(0); 
include '../c/config.php';

$mysqli = new mysqli($dbhost, $dbuser, $dbpwd, $dbName);
if (!$mysqli->set_charset("utf8")) {printf("Error loading character set utf8: %s\n", $mysqli->error);}

 
$j=0;
$query=$mysqli->query("select uid from uinfo where 
uid !='oE4KPwWWre5uH33b4qHlgAm2pOXo'
and	quchong is NULL group by uid having count(uid) >1 ORDER BY `uinfo`.`uid` ASC ");
while ($list=$query->fetch_array()) {
      $uid=$list['uid'];

      echo  $uid;
      echo "<br /><br />";
     
     $queryD=$mysqli->query("select * from uinfo WHERE uid ='".$uid."' and quchong is NULL  ");
     
     $a=$b=$c=array();
     $i=1;
     while ($listD=$queryD->fetch_assoc()) {
          var_dump($listD);
           echo "<br /><br />";
        if(1 == $i){
           $a=$listD;
        }
        if(2 == $i){
           $b=$listD;	
        }
        if(3 == $i){
           $c=$listD;	
        }
        $i++;
     }
     
     if (!empty($b)) {
     	 if ($b['name'] == $a['name'] 
     	 	&&
     	 	$b['phone'] == $a['phone']
     	 	&&
     	 	$b['email'] == $a['email']
     	 	&&
     	 	$b['uid'] == $a['uid']
     	 	&&
     	 	$b['idcard'] == $a['idcard']
     	 	&&
     	 	$b['nianji'] == $a['nianji']
     	 	 ) {
     	 	 
     	 	 echo "b: ",$b['id'];

     	 	echo "<br /><br />";
     	 	$sql="update uinfo set quchong='1' where id='".$b['id']."' ";
             echo $sql;
             $mysqli->query($sql);
             echo "<br /><br />";
     	 }
     }

     if (!empty($c)) {
     	 if ($c['name'] == $a['name'] 
     	 	&&
     	 	$c['phone'] == $a['phone']
     	 	&&
     	 	$c['email'] == $a['email']
     	 	&&
     	 	$c['uid'] == $a['uid']
     	 	&&
     	 	$c['idcard'] == $a['idcard']
     	 	&&
     	 	$c['nianji'] == $a['nianji']
     	 	 ) {
     	 	 
     	 	 echo "c: ",$c['id'];
     	 	echo "<br /><br />";
             $sql="update uinfo set quchong='1' where id='".$c['id']."' ";
             echo $sql;
             $mysqli->query($sql);
              
     	 	
     	 }
     }

?>
<script type="text/javascript">
    window.setTimeout(function(){
         window.location.reload();
    }, 400);

</script>
<?php
   
    exit;
}

?>